package com.lqe.study.Servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Properties;

@WebServlet("/ServletDemo05")
public class ServletDemo05 extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req,resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("utf-8");
        req.setCharacterEncoding("utf-8");

        System.out.println("进来咯");
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        System.out.println(username+"："+password);
        String[] parameterValues = req.getParameterValues("hobby");
        System.out.println(Arrays.toString(parameterValues));
        for (String value:parameterValues) {
            System.out.println(value);
        }



        req.setAttribute("username",username);
        req.setAttribute("password",password);
        //resp.sendRedirect(req.getContextPath()+"/success.jsp");
        req.getRequestDispatcher(req.getContextPath()+"/"+"success.jsp");


    }
}


